#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using pii = pair < int , int >;
using vec = vector < int >;
using veg = vector < pii >;
using ll = long long;
using db = double;
using tl = tuple < int, int, int >;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

string s;

string trans(string s) {
	string res = "?#";
	for(auto x : s) res += x, res += '#';
	res += "|"; return res;
}

const int N = 2.5e7 + 10;

int p[N];

void manacher(string s) {
	int mx = -1, ps = -1, l = s.size();
	int ans = 0;
	rep(i, 0, l - 1) {
		if(i <= mx) p[i] = min(mx - i + 1, p[ps * 2 - i]);
		while(i + p[i] < l && p[i] <= i && s[p[i] + i] == s[i - p[i]]) p[i]++;
		if(i + p[i] - 1 >= mx) mx = i + p[i] - 1, ps = i;
		ans = max(ans, p[i]);
	} printf("%d\n", ans - 1);
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
	ios :: sync_with_stdio(false); cin.tie(0);
	cin >> s; s = trans(s);
	manacher(s);
}
